{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# NBA Win-Loss Modeling Data Prep"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "\n",
    "This Jupyter Notebook script will walk you through the process of engineering features using Team, Player, and Game data for the purpose of creating an NBA Home Team Win-Loss Binary Classification Model. Follow the link for inuition around the model https://medium.com/@theresearchlab/create-an-nba-win-loss-model-w-68-precision-d1c6a21f0ded"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from nba_api.stats.static import teams, players\n",
    "from nba_api.stats.endpoints import cumestatsteamgames, cumestatsteam, gamerotation\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import json\n",
    "import difflib\n",
    "import time\n",
    "import requests"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "implement a retry wrapper using a python decorator function. This will prevent the HTTP Timeouts from stopping the script's run during API calls. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Retry Wrapper \n",
    "def retry(func, retries=3):\n",
    "    def retry_wrapper(*args, **kwargs):\n",
    "        attempts = 0\n",
    "        while attempts < retries:\n",
    "            try:\n",
    "                return func(*args, **kwargs)\n",
    "            except requests.exceptions.RequestException as e:\n",
    "                print(e)\n",
    "                time.sleep(30)\n",
    "                attempts += 1\n",
    "\n",
    "    return retry_wrapper"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Get Season Schedule Function \n",
    "\n",
    "def getSeasonScheduleFrame(seasons,seasonType): \n",
    "\n",
    "    # Get date from string\n",
    "    def getGameDate(matchup):\n",
    "        return matchup.partition(' at')[0][:10]\n",
    "\n",
    "    # Get Home team from string\n",
    "    def getHomeTeam(matchup):\n",
    "        return matchup.partition(' at')[2]\n",
    "\n",
    "    # Get Away team from string\n",
    "    def getAwayTeam(matchup):\n",
    "        return matchup.partition(' at')[0][10:]\n",
    "\n",
    "    # Match nickname from schedule to team table to find ID\n",
    "    def getTeamIDFromNickname(nickname):\n",
    "        return teamLookup.loc[teamLookup['nickname'] == difflib.get_close_matches(nickname,teamLookup['nickname'],1)[0]].values[0][0] \n",
    "    \n",
    "    @retry\n",
    "    def getRegularSeasonSchedule(season,teamID,seasonType):\n",
    "        season = str(season) + \"-\" + str(season+1)[-2:] # Convert year to season format ie. 2020 -> 2020-21\n",
    "        teamGames = cumestatsteamgames.CumeStatsTeamGames(league_id = '00',season = season ,\n",
    "                                                                      season_type_all_star=seasonType,\n",
    "                                                                      team_id = teamID).get_normalized_json()\n",
    "\n",
    "        teamGames = pd.DataFrame(json.loads(teamGames)['CumeStatsTeamGames'])\n",
    "        teamGames['SEASON'] = season\n",
    "        return teamGames    \n",
    "    \n",
    "    # Get team lookup table\n",
    "    teamLookup = pd.DataFrame(teams.get_teams())\n",
    "    \n",
    "    # Get teams schedule for each team for each season\n",
    "    scheduleFrame = pd.DataFrame()\n",
    "\n",
    "    for season in seasons:\n",
    "        for id in teamLookup['id']:\n",
    "            time.sleep(1)\n",
    "            scheduleFrame = scheduleFrame.append(getRegularSeasonSchedule(season,id,seasonType))\n",
    "            \n",
    "    scheduleFrame['GAME_DATE'] = pd.to_datetime(scheduleFrame['MATCHUP'].map(getGameDate))\n",
    "    scheduleFrame['HOME_TEAM_NICKNAME'] = scheduleFrame['MATCHUP'].map(getHomeTeam)\n",
    "    scheduleFrame['HOME_TEAM_ID'] = scheduleFrame['HOME_TEAM_NICKNAME'].map(getTeamIDFromNickname)\n",
    "    scheduleFrame['AWAY_TEAM_NICKNAME'] = scheduleFrame['MATCHUP'].map(getAwayTeam)\n",
    "    scheduleFrame['AWAY_TEAM_ID'] = scheduleFrame['AWAY_TEAM_NICKNAME'].map(getTeamIDFromNickname)\n",
    "    scheduleFrame = scheduleFrame.drop_duplicates() # There's a row for both teams, only need 1\n",
    "    scheduleFrame = scheduleFrame.reset_index(drop=True)\n",
    "            \n",
    "    return scheduleFrame\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Get Single Game aggregation columns\n",
    "\n",
    "def getSingleGameMetrics(gameID,homeTeamID,awayTeamID,awayTeamNickname,seasonYear,gameDate):\n",
    "\n",
    "    @retry\n",
    "    def getGameStats(teamID,gameID,seasonYear):\n",
    "        gameStats = cumestatsteam.CumeStatsTeam(game_ids=gameID,league_id =\"00\",\n",
    "                                               season=seasonYear,season_type_all_star=\"Regular Season\",\n",
    "                                               team_id = teamID).get_normalized_json()\n",
    "\n",
    "        gameStats = pd.DataFrame(json.loads(gameStats)['TotalTeamStats'])\n",
    "\n",
    "        return gameStats\n",
    "\n",
    "    data = getGameStats(homeTeamID,gameID,seasonYear)\n",
    "    data.at[1,'NICKNAME'] = awayTeamNickname\n",
    "    data.at[1,'TEAM_ID'] = awayTeamID\n",
    "    data.at[1,'OFFENSIVE_EFFICIENCY'] = (data.at[1,'FG'] + data.at[1,'AST'])/(data.at[1,'FGA'] - data.at[1,'OFF_REB'] + data.at[1,'AST'] + data.at[1,'TOTAL_TURNOVERS'])\n",
    "    data.at[1,'SCORING_MARGIN'] = data.at[1,'PTS'] - data.at[0,'PTS']\n",
    "\n",
    "    data.at[0,'OFFENSIVE_EFFICIENCY'] = (data.at[0,'FG'] + data.at[0,'AST'])/(data.at[0,'FGA'] - data.at[0,'OFF_REB'] + data.at[0,'AST'] + data.at[0,'TOTAL_TURNOVERS'])\n",
    "    data.at[0,'SCORING_MARGIN'] = data.at[0,'PTS'] - data.at[1,'PTS']\n",
    "\n",
    "    data['SEASON'] = seasonYear\n",
    "    data['GAME_DATE'] = gameDate\n",
    "    data['GAME_ID'] = gameID\n",
    "\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def getGameLogs(gameLogs,scheduleFrame):\n",
    "    \n",
    "    # Functions to prepare additional columns after gameLogs table loads\n",
    "    def getHomeAwayFlag(gameDF):\n",
    "        gameDF['HOME_FLAG'] = np.where((gameDF['W_HOME']==1) | (gameDF['L_HOME']==1),1,0)\n",
    "        gameDF['AWAY_FLAG'] = np.where((gameDF['W_ROAD']==1) | (gameDF['L_ROAD']==1),1,0) \n",
    "\n",
    "    def getTotalWinPctg(gameDF):\n",
    "        gameDF['TOTAL_GAMES_PLAYED'] = gameDF.groupby(['TEAM_ID','SEASON'])['GAME_DATE'].rank(ascending=True)\n",
    "        gameDF['TOTAL_WINS'] = gameDF.sort_values(by='GAME_DATE').groupby(['TEAM_ID','SEASON'])['W'].cumsum()\n",
    "        gameDF['TOTAL_WIN_PCTG'] = gameDF['TOTAL_WINS']/gameDF['TOTAL_GAMES_PLAYED']\n",
    "        return gameDF.drop(['TOTAL_GAMES_PLAYED','TOTAL_WINS'],axis=1)\n",
    "\n",
    "    def getHomeWinPctg(gameDF):\n",
    "        gameDF['HOME_GAMES_PLAYED'] = gameDF.sort_values(by='GAME_DATE').groupby(['TEAM_ID','SEASON'])['HOME_FLAG'].cumsum()\n",
    "        gameDF['HOME_WINS'] = gameDF.sort_values(by='GAME_DATE').groupby(['TEAM_ID','SEASON'])['W_HOME'].cumsum()\n",
    "        gameDF['HOME_WIN_PCTG'] = gameDF['HOME_WINS']/gameDF['HOME_GAMES_PLAYED']\n",
    "        return gameDF.drop(['HOME_GAMES_PLAYED','HOME_WINS'],axis=1)\n",
    "\n",
    "    def getAwayWinPctg(gameDF):\n",
    "        gameDF['AWAY_GAMES_PLAYED'] = gameDF.sort_values(by='GAME_DATE').groupby(['TEAM_ID','SEASON'])['AWAY_FLAG'].cumsum()\n",
    "        gameDF['AWAY_WINS'] = gameDF.sort_values(by='GAME_DATE').groupby(['TEAM_ID','SEASON'])['W_ROAD'].cumsum()\n",
    "        gameDF['AWAY_WIN_PCTG'] = gameDF['AWAY_WINS']/gameDF['AWAY_GAMES_PLAYED']\n",
    "        return gameDF.drop(['AWAY_GAMES_PLAYED','AWAY_WINS'],axis=1)\n",
    "\n",
    "    def getRollingOE(gameDF):\n",
    "        gameDF['ROLLING_OE'] = gameDF.sort_values(by='GAME_DATE').groupby(['TEAM_ID','SEASON'])['OFFENSIVE_EFFICIENCY'].transform(lambda x: x.rolling(3, 1).mean())\n",
    "\n",
    "    def getRollingScoringMargin(gameDF):\n",
    "        gameDF['ROLLING_SCORING_MARGIN'] = gameDF.sort_values(by='GAME_DATE').groupby(['TEAM_ID','SEASON'])['SCORING_MARGIN'].transform(lambda x: x.rolling(3, 1).mean())\n",
    "\n",
    "    def getRestDays(gameDF):\n",
    "        gameDF['LAST_GAME_DATE'] = gameDF.sort_values(by='GAME_DATE').groupby(['TEAM_ID','SEASON'])['GAME_DATE'].shift(1)\n",
    "        gameDF['NUM_REST_DAYS'] = (gameDF['GAME_DATE'] - gameDF['LAST_GAME_DATE'])/np.timedelta64(1,'D') \n",
    "        return gameDF.drop('LAST_GAME_DATE',axis=1)\n",
    "    \n",
    "    start = time.perf_counter_ns()\n",
    "\n",
    "    i = int(len(gameLogs)/2) #Can use a previously completed gameLog dataset\n",
    "\n",
    "    while i<len(scheduleFrame):\n",
    "\n",
    "\n",
    "        time.sleep(1)\n",
    "        gameLogs =  gameLogs.append(getSingleGameMetrics(scheduleFrame.at[i,'GAME_ID'],scheduleFrame.at[i,'HOME_TEAM_ID'],\n",
    "                         scheduleFrame.at[i,'AWAY_TEAM_ID'],scheduleFrame.at[i,'AWAY_TEAM_NICKNAME'],\n",
    "                         scheduleFrame.at[i,'SEASON'],scheduleFrame.at[i,'GAME_DATE']))\n",
    "        \n",
    "        gameLogs = gameLogs.reset_index(drop=True)\n",
    "\n",
    "        end = time.perf_counter_ns()\n",
    "\n",
    "        #Output time it took to load x amount of records\n",
    "        if i%100 == 0:\n",
    "            mins = ((end-start)/1e9)/60\n",
    "            print(i,str(mins) + ' minutes')\n",
    "\n",
    "        i+=1\n",
    "        \n",
    "    # Get Table Level Aggregation Columns\n",
    "    getHomeAwayFlag(gameLogs)\n",
    "    gameLogs = getHomeWinPctg(gameLogs)\n",
    "    gameLogs = getAwayWinPctg(gameLogs)\n",
    "    gameLogs = getTotalWinPctg(gameLogs)\n",
    "    getRollingScoringMargin(gameLogs)\n",
    "    getRollingOE(gameLogs)\n",
    "    gameLogs = getRestDays(gameLogs)\n",
    "\n",
    "    return gameLogs.reset_index(drop=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2.7492755266666666\n"
     ]
    }
   ],
   "source": [
    "#Get ScheduleFrame\n",
    "\n",
    "seasons = [2020,2021,2022]\n",
    "seasonType = 'Regular Season'\n",
    "\n",
    "start = time.perf_counter_ns() # Track cell's runtime\n",
    "scheduleFrame = getSeasonScheduleFrame(seasons,seasonType)\n",
    "end = time.perf_counter_ns()\n",
    "\n",
    "secs = (end-start)/1e9\n",
    "mins = secs/60\n",
    "print(mins)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>CITY</th>\n",
       "      <th>NICKNAME</th>\n",
       "      <th>TEAM_ID</th>\n",
       "      <th>W</th>\n",
       "      <th>L</th>\n",
       "      <th>W_HOME</th>\n",
       "      <th>L_HOME</th>\n",
       "      <th>W_ROAD</th>\n",
       "      <th>L_ROAD</th>\n",
       "      <th>TEAM_TURNOVERS</th>\n",
       "      <th>...</th>\n",
       "      <th>BLK</th>\n",
       "      <th>PTS</th>\n",
       "      <th>AVG_REB</th>\n",
       "      <th>AVG_PTS</th>\n",
       "      <th>DQ</th>\n",
       "      <th>OFFENSIVE_EFFICIENCY</th>\n",
       "      <th>SCORING_MARGIN</th>\n",
       "      <th>SEASON</th>\n",
       "      <th>GAME_DATE</th>\n",
       "      <th>GAME_ID</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Cleveland</td>\n",
       "      <td>Cavaliers</td>\n",
       "      <td>1610612739</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>3</td>\n",
       "      <td>117</td>\n",
       "      <td>49.0</td>\n",
       "      <td>117.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.588785</td>\n",
       "      <td>7.0</td>\n",
       "      <td>2020-21</td>\n",
       "      <td>2021-03-17</td>\n",
       "      <td>0022000620</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Celtics</td>\n",
       "      <td>1610612738</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>9</td>\n",
       "      <td>110</td>\n",
       "      <td>48.0</td>\n",
       "      <td>110.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.567308</td>\n",
       "      <td>-7.0</td>\n",
       "      <td>2020-21</td>\n",
       "      <td>2021-03-17</td>\n",
       "      <td>0022000620</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2 rows × 41 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        CITY   NICKNAME     TEAM_ID  W  L  W_HOME  L_HOME  W_ROAD  L_ROAD  \\\n",
       "0  Cleveland  Cavaliers  1610612739  1  0       1       0       0       0   \n",
       "1  OPPONENTS    Celtics  1610612738  0  1       0       0       0       1   \n",
       "\n",
       "   TEAM_TURNOVERS  ...  BLK  PTS  AVG_REB  AVG_PTS  DQ  OFFENSIVE_EFFICIENCY  \\\n",
       "0               2  ...    3  117     49.0    117.0   0              0.588785   \n",
       "1               0  ...    9  110     48.0    110.0   0              0.567308   \n",
       "\n",
       "   SCORING_MARGIN   SEASON  GAME_DATE     GAME_ID  \n",
       "0             7.0  2020-21 2021-03-17  0022000620  \n",
       "1            -7.0  2020-21 2021-03-17  0022000620  \n",
       "\n",
       "[2 rows x 41 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Example Output of Single Game Metrics\n",
    "getSingleGameMetrics(scheduleFrame.at[104,'GAME_ID'],scheduleFrame.at[104,'HOME_TEAM_ID'],\n",
    "                     scheduleFrame.at[104,'AWAY_TEAM_ID'],scheduleFrame.at[104,'AWAY_TEAM_NICKNAME'],\n",
    "                     scheduleFrame.at[104,'SEASON'],scheduleFrame.at[104,'GAME_DATE'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 0.027592645000000002\n",
      "100 3.761211635\n",
      "200 7.446148228333333\n",
      "300 10.91657379\n",
      "400 14.178322275\n",
      "500 17.562468318333334\n",
      "600 22.57064343333333\n",
      "700 28.885029056666667\n",
      "800 32.53894844333333\n",
      "900 36.77510828333333\n",
      "1000 41.57496655333333\n",
      "1100 45.66484153166667\n",
      "1200 48.904151811666665\n",
      "1300 52.46264781666666\n",
      "1400 55.85839063666666\n",
      "1500 60.04402927833333\n",
      "1600 64.00290142\n",
      "1700 67.65499090166666\n",
      "1800 71.13305232833333\n",
      "1900 75.12400890166667\n",
      "2000 78.45767208000001\n",
      "2100 82.388200135\n",
      "2200 85.89361625166666\n",
      "2300 90.73073644\n",
      "2400 92.95489135999999\n",
      "2500 95.15283247333333\n",
      "2600 97.83685436833333\n",
      "2700 101.011523535\n",
      "2800 104.15464245833333\n",
      "2900 108.15016159333332\n"
     ]
    }
   ],
   "source": [
    "#Create the gameLogs DataFrame\n",
    "gameLogs = pd.DataFrame()\n",
    "gameLogs = getGameLogs(gameLogs,scheduleFrame)\n",
    "gameLogs.to_csv('gameLogs.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>CITY</th>\n",
       "      <th>NICKNAME</th>\n",
       "      <th>TEAM_ID</th>\n",
       "      <th>W</th>\n",
       "      <th>L</th>\n",
       "      <th>W_HOME</th>\n",
       "      <th>L_HOME</th>\n",
       "      <th>W_ROAD</th>\n",
       "      <th>L_ROAD</th>\n",
       "      <th>TEAM_TURNOVERS</th>\n",
       "      <th>...</th>\n",
       "      <th>GAME_DATE</th>\n",
       "      <th>GAME_ID</th>\n",
       "      <th>HOME_FLAG</th>\n",
       "      <th>AWAY_FLAG</th>\n",
       "      <th>HOME_WIN_PCTG</th>\n",
       "      <th>AWAY_WIN_PCTG</th>\n",
       "      <th>TOTAL_WIN_PCTG</th>\n",
       "      <th>ROLLING_SCORING_MARGIN</th>\n",
       "      <th>ROLLING_OE</th>\n",
       "      <th>NUM_REST_DAYS</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>4696</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-10-19</td>\n",
       "      <td>0022200005</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>10.000000</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4694</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-10-21</td>\n",
       "      <td>0022200020</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>10.000000</td>\n",
       "      <td>0.568293</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4692</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-10-23</td>\n",
       "      <td>0022200038</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.560148</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4691</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-10-26</td>\n",
       "      <td>0022200057</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.750000</td>\n",
       "      <td>-0.666667</td>\n",
       "      <td>0.554351</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4689</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-10-28</td>\n",
       "      <td>0022200070</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.800000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>0.604823</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4687</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-10-29</td>\n",
       "      <td>0022200085</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>7.000000</td>\n",
       "      <td>0.610671</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4685</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-10-31</td>\n",
       "      <td>0022200099</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.571429</td>\n",
       "      <td>-4.666667</td>\n",
       "      <td>0.598040</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4683</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-11-02</td>\n",
       "      <td>0022200110</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>0.625000</td>\n",
       "      <td>-8.333333</td>\n",
       "      <td>0.557683</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4680</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-11-05</td>\n",
       "      <td>0022200134</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.750000</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>-4.666667</td>\n",
       "      <td>0.559942</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4678</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-11-07</td>\n",
       "      <td>0022200149</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.800000</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>0.700000</td>\n",
       "      <td>11.666667</td>\n",
       "      <td>0.566895</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4676</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-11-09</td>\n",
       "      <td>0022200162</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>0.636364</td>\n",
       "      <td>5.333333</td>\n",
       "      <td>0.574769</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4674</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-11-10</td>\n",
       "      <td>0022200173</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.714286</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>7.333333</td>\n",
       "      <td>0.554966</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4673</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-11-12</td>\n",
       "      <td>0022200188</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.714286</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.615385</td>\n",
       "      <td>-3.000000</td>\n",
       "      <td>0.538855</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4671</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-11-14</td>\n",
       "      <td>0022200204</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.714286</td>\n",
       "      <td>0.571429</td>\n",
       "      <td>0.642857</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>0.543206</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4668</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-11-16</td>\n",
       "      <td>0022200214</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.625000</td>\n",
       "      <td>0.571429</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>-7.333333</td>\n",
       "      <td>0.553102</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4666</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-11-19</td>\n",
       "      <td>0022200235</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.571429</td>\n",
       "      <td>0.625000</td>\n",
       "      <td>-2.666667</td>\n",
       "      <td>0.573966</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4665</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-11-21</td>\n",
       "      <td>0022200248</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.588235</td>\n",
       "      <td>-11.666667</td>\n",
       "      <td>0.547906</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4662</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-11-23</td>\n",
       "      <td>0022200263</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.700000</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.611111</td>\n",
       "      <td>-0.333333</td>\n",
       "      <td>0.549210</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4661</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-11-25</td>\n",
       "      <td>0022200278</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.700000</td>\n",
       "      <td>0.444444</td>\n",
       "      <td>0.578947</td>\n",
       "      <td>-3.000000</td>\n",
       "      <td>0.525804</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4658</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-11-27</td>\n",
       "      <td>0022200293</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.636364</td>\n",
       "      <td>0.444444</td>\n",
       "      <td>0.550000</td>\n",
       "      <td>-1.666667</td>\n",
       "      <td>0.520203</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4657</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-11-28</td>\n",
       "      <td>0022200299</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.636364</td>\n",
       "      <td>0.400000</td>\n",
       "      <td>0.523810</td>\n",
       "      <td>-5.666667</td>\n",
       "      <td>0.526912</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4655</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-11-30</td>\n",
       "      <td>0022200313</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.636364</td>\n",
       "      <td>0.454545</td>\n",
       "      <td>0.545455</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>0.573564</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4652</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-12-02</td>\n",
       "      <td>0022200327</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.454545</td>\n",
       "      <td>0.565217</td>\n",
       "      <td>7.333333</td>\n",
       "      <td>0.621286</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4650</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-12-05</td>\n",
       "      <td>0022200354</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.615385</td>\n",
       "      <td>0.454545</td>\n",
       "      <td>0.541667</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>0.612264</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4649</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-12-07</td>\n",
       "      <td>0022200365</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.615385</td>\n",
       "      <td>0.416667</td>\n",
       "      <td>0.520000</td>\n",
       "      <td>-7.666667</td>\n",
       "      <td>0.554155</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4647</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-12-09</td>\n",
       "      <td>0022200380</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.615385</td>\n",
       "      <td>0.384615</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>-11.666667</td>\n",
       "      <td>0.523005</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4644</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-12-11</td>\n",
       "      <td>0022200400</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.642857</td>\n",
       "      <td>0.384615</td>\n",
       "      <td>0.518519</td>\n",
       "      <td>-9.000000</td>\n",
       "      <td>0.532497</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4643</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-12-12</td>\n",
       "      <td>0022200404</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.642857</td>\n",
       "      <td>0.357143</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>-9.333333</td>\n",
       "      <td>0.532414</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4641</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-12-14</td>\n",
       "      <td>0022200416</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.642857</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>0.482759</td>\n",
       "      <td>-11.666667</td>\n",
       "      <td>0.551859</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4639</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-12-16</td>\n",
       "      <td>0022200428</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.642857</td>\n",
       "      <td>0.375000</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>-5.666667</td>\n",
       "      <td>0.563889</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4636</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-12-19</td>\n",
       "      <td>0022200454</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.375000</td>\n",
       "      <td>0.516129</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>0.607655</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4634</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-12-21</td>\n",
       "      <td>0022200468</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.625000</td>\n",
       "      <td>0.375000</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>0.572968</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4632</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-12-23</td>\n",
       "      <td>0022200481</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.647059</td>\n",
       "      <td>0.375000</td>\n",
       "      <td>0.515152</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>0.588815</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4631</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-12-27</td>\n",
       "      <td>0022200508</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.647059</td>\n",
       "      <td>0.352941</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>2.666667</td>\n",
       "      <td>0.578020</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4628</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-12-28</td>\n",
       "      <td>0022200517</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.611111</td>\n",
       "      <td>0.352941</td>\n",
       "      <td>0.485714</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>0.597628</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4626</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2022-12-30</td>\n",
       "      <td>0022200530</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.578947</td>\n",
       "      <td>0.352941</td>\n",
       "      <td>0.472222</td>\n",
       "      <td>-8.333333</td>\n",
       "      <td>0.574618</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4625</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2023-01-02</td>\n",
       "      <td>0022200558</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.578947</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>0.459459</td>\n",
       "      <td>-4.000000</td>\n",
       "      <td>0.578149</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4623</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>2023-01-04</td>\n",
       "      <td>0022200575</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.578947</td>\n",
       "      <td>0.368421</td>\n",
       "      <td>0.473684</td>\n",
       "      <td>-2.666667</td>\n",
       "      <td>0.580656</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4621</th>\n",
       "      <td>OPPONENTS</td>\n",
       "      <td>Hawks</td>\n",
       "      <td>1610612737</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2023-01-06</td>\n",
       "      <td>0022200590</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.578947</td>\n",
       "      <td>0.350000</td>\n",
       "      <td>0.461538</td>\n",
       "      <td>-5.000000</td>\n",
       "      <td>0.569151</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>39 rows × 49 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           CITY NICKNAME     TEAM_ID  W  L  W_HOME  L_HOME  W_ROAD  L_ROAD  \\\n",
       "4696    Atlanta    Hawks  1610612737  1  0       1       0       0       0   \n",
       "4694    Atlanta    Hawks  1610612737  1  0       1       0       0       0   \n",
       "4692    Atlanta    Hawks  1610612737  0  1       0       1       0       0   \n",
       "4691  OPPONENTS    Hawks  1610612737  1  0       0       0       1       0   \n",
       "4689  OPPONENTS    Hawks  1610612737  1  0       0       0       1       0   \n",
       "4687  OPPONENTS    Hawks  1610612737  0  1       0       0       0       1   \n",
       "4685  OPPONENTS    Hawks  1610612737  0  1       0       0       0       1   \n",
       "4683  OPPONENTS    Hawks  1610612737  1  0       0       0       1       0   \n",
       "4680    Atlanta    Hawks  1610612737  1  0       1       0       0       0   \n",
       "4678    Atlanta    Hawks  1610612737  1  0       1       0       0       0   \n",
       "4676    Atlanta    Hawks  1610612737  0  1       0       1       0       0   \n",
       "4674    Atlanta    Hawks  1610612737  1  0       1       0       0       0   \n",
       "4673  OPPONENTS    Hawks  1610612737  0  1       0       0       0       1   \n",
       "4671  OPPONENTS    Hawks  1610612737  1  0       0       0       1       0   \n",
       "4668    Atlanta    Hawks  1610612737  0  1       0       1       0       0   \n",
       "4666    Atlanta    Hawks  1610612737  1  0       1       0       0       0   \n",
       "4665  OPPONENTS    Hawks  1610612737  0  1       0       0       0       1   \n",
       "4662    Atlanta    Hawks  1610612737  1  0       1       0       0       0   \n",
       "4661  OPPONENTS    Hawks  1610612737  0  1       0       0       0       1   \n",
       "4658    Atlanta    Hawks  1610612737  0  1       0       1       0       0   \n",
       "4657  OPPONENTS    Hawks  1610612737  0  1       0       0       0       1   \n",
       "4655  OPPONENTS    Hawks  1610612737  1  0       0       0       1       0   \n",
       "4652    Atlanta    Hawks  1610612737  1  0       1       0       0       0   \n",
       "4650    Atlanta    Hawks  1610612737  0  1       0       1       0       0   \n",
       "4649  OPPONENTS    Hawks  1610612737  0  1       0       0       0       1   \n",
       "4647  OPPONENTS    Hawks  1610612737  0  1       0       0       0       1   \n",
       "4644    Atlanta    Hawks  1610612737  1  0       1       0       0       0   \n",
       "4643  OPPONENTS    Hawks  1610612737  0  1       0       0       0       1   \n",
       "4641  OPPONENTS    Hawks  1610612737  0  1       0       0       0       1   \n",
       "4639  OPPONENTS    Hawks  1610612737  1  0       0       0       1       0   \n",
       "4636    Atlanta    Hawks  1610612737  1  0       1       0       0       0   \n",
       "4634    Atlanta    Hawks  1610612737  0  1       0       1       0       0   \n",
       "4632    Atlanta    Hawks  1610612737  1  0       1       0       0       0   \n",
       "4631  OPPONENTS    Hawks  1610612737  0  1       0       0       0       1   \n",
       "4628    Atlanta    Hawks  1610612737  0  1       0       1       0       0   \n",
       "4626    Atlanta    Hawks  1610612737  0  1       0       1       0       0   \n",
       "4625  OPPONENTS    Hawks  1610612737  0  1       0       0       0       1   \n",
       "4623  OPPONENTS    Hawks  1610612737  1  0       0       0       1       0   \n",
       "4621  OPPONENTS    Hawks  1610612737  0  1       0       0       0       1   \n",
       "\n",
       "      TEAM_TURNOVERS  ...  GAME_DATE     GAME_ID  HOME_FLAG  AWAY_FLAG  \\\n",
       "4696               0  ... 2022-10-19  0022200005          1          0   \n",
       "4694               0  ... 2022-10-21  0022200020          1          0   \n",
       "4692               0  ... 2022-10-23  0022200038          1          0   \n",
       "4691               0  ... 2022-10-26  0022200057          0          1   \n",
       "4689               1  ... 2022-10-28  0022200070          0          1   \n",
       "4687               1  ... 2022-10-29  0022200085          0          1   \n",
       "4685               0  ... 2022-10-31  0022200099          0          1   \n",
       "4683               2  ... 2022-11-02  0022200110          0          1   \n",
       "4680               0  ... 2022-11-05  0022200134          1          0   \n",
       "4678               0  ... 2022-11-07  0022200149          1          0   \n",
       "4676               0  ... 2022-11-09  0022200162          1          0   \n",
       "4674               0  ... 2022-11-10  0022200173          1          0   \n",
       "4673               1  ... 2022-11-12  0022200188          0          1   \n",
       "4671               0  ... 2022-11-14  0022200204          0          1   \n",
       "4668               0  ... 2022-11-16  0022200214          1          0   \n",
       "4666               1  ... 2022-11-19  0022200235          1          0   \n",
       "4665               1  ... 2022-11-21  0022200248          0          1   \n",
       "4662               0  ... 2022-11-23  0022200263          1          0   \n",
       "4661               1  ... 2022-11-25  0022200278          0          1   \n",
       "4658               3  ... 2022-11-27  0022200293          1          0   \n",
       "4657               1  ... 2022-11-28  0022200299          0          1   \n",
       "4655               0  ... 2022-11-30  0022200313          0          1   \n",
       "4652               0  ... 2022-12-02  0022200327          1          0   \n",
       "4650               0  ... 2022-12-05  0022200354          1          0   \n",
       "4649               0  ... 2022-12-07  0022200365          0          1   \n",
       "4647               0  ... 2022-12-09  0022200380          0          1   \n",
       "4644               1  ... 2022-12-11  0022200400          1          0   \n",
       "4643               1  ... 2022-12-12  0022200404          0          1   \n",
       "4641               0  ... 2022-12-14  0022200416          0          1   \n",
       "4639               2  ... 2022-12-16  0022200428          0          1   \n",
       "4636               0  ... 2022-12-19  0022200454          1          0   \n",
       "4634               0  ... 2022-12-21  0022200468          1          0   \n",
       "4632               0  ... 2022-12-23  0022200481          1          0   \n",
       "4631               0  ... 2022-12-27  0022200508          0          1   \n",
       "4628               1  ... 2022-12-28  0022200517          1          0   \n",
       "4626               0  ... 2022-12-30  0022200530          1          0   \n",
       "4625               0  ... 2023-01-02  0022200558          0          1   \n",
       "4623               1  ... 2023-01-04  0022200575          0          1   \n",
       "4621               0  ... 2023-01-06  0022200590          0          1   \n",
       "\n",
       "      HOME_WIN_PCTG  AWAY_WIN_PCTG  TOTAL_WIN_PCTG  ROLLING_SCORING_MARGIN  \\\n",
       "4696       1.000000            NaN        1.000000               10.000000   \n",
       "4694       1.000000            NaN        1.000000               10.000000   \n",
       "4692       0.666667            NaN        0.666667                1.000000   \n",
       "4691       0.666667       1.000000        0.750000               -0.666667   \n",
       "4689       0.666667       1.000000        0.800000                4.000000   \n",
       "4687       0.666667       0.666667        0.666667                7.000000   \n",
       "4685       0.666667       0.500000        0.571429               -4.666667   \n",
       "4683       0.666667       0.600000        0.625000               -8.333333   \n",
       "4680       0.750000       0.600000        0.666667               -4.666667   \n",
       "4678       0.800000       0.600000        0.700000               11.666667   \n",
       "4676       0.666667       0.600000        0.636364                5.333333   \n",
       "4674       0.714286       0.600000        0.666667                7.333333   \n",
       "4673       0.714286       0.500000        0.615385               -3.000000   \n",
       "4671       0.714286       0.571429        0.642857                4.000000   \n",
       "4668       0.625000       0.571429        0.600000               -7.333333   \n",
       "4666       0.666667       0.571429        0.625000               -2.666667   \n",
       "4665       0.666667       0.500000        0.588235              -11.666667   \n",
       "4662       0.700000       0.500000        0.611111               -0.333333   \n",
       "4661       0.700000       0.444444        0.578947               -3.000000   \n",
       "4658       0.636364       0.444444        0.550000               -1.666667   \n",
       "4657       0.636364       0.400000        0.523810               -5.666667   \n",
       "4655       0.636364       0.454545        0.545455                2.000000   \n",
       "4652       0.666667       0.454545        0.565217                7.333333   \n",
       "4650       0.615385       0.454545        0.541667                6.000000   \n",
       "4649       0.615385       0.416667        0.520000               -7.666667   \n",
       "4647       0.615385       0.384615        0.500000              -11.666667   \n",
       "4644       0.642857       0.384615        0.518519               -9.000000   \n",
       "4643       0.642857       0.357143        0.500000               -9.333333   \n",
       "4641       0.642857       0.333333        0.482759              -11.666667   \n",
       "4639       0.642857       0.375000        0.500000               -5.666667   \n",
       "4636       0.666667       0.375000        0.516129                3.000000   \n",
       "4634       0.625000       0.375000        0.500000                6.000000   \n",
       "4632       0.647059       0.375000        0.515152                8.000000   \n",
       "4631       0.647059       0.352941        0.500000                2.666667   \n",
       "4628       0.611111       0.352941        0.485714                3.000000   \n",
       "4626       0.578947       0.352941        0.472222               -8.333333   \n",
       "4625       0.578947       0.333333        0.459459               -4.000000   \n",
       "4623       0.578947       0.368421        0.473684               -2.666667   \n",
       "4621       0.578947       0.350000        0.461538               -5.000000   \n",
       "\n",
       "      ROLLING_OE  NUM_REST_DAYS  \n",
       "4696    0.600000            NaN  \n",
       "4694    0.568293            2.0  \n",
       "4692    0.560148            2.0  \n",
       "4691    0.554351            3.0  \n",
       "4689    0.604823            2.0  \n",
       "4687    0.610671            1.0  \n",
       "4685    0.598040            2.0  \n",
       "4683    0.557683            2.0  \n",
       "4680    0.559942            3.0  \n",
       "4678    0.566895            2.0  \n",
       "4676    0.574769            2.0  \n",
       "4674    0.554966            1.0  \n",
       "4673    0.538855            2.0  \n",
       "4671    0.543206            2.0  \n",
       "4668    0.553102            2.0  \n",
       "4666    0.573966            3.0  \n",
       "4665    0.547906            2.0  \n",
       "4662    0.549210            2.0  \n",
       "4661    0.525804            2.0  \n",
       "4658    0.520203            2.0  \n",
       "4657    0.526912            1.0  \n",
       "4655    0.573564            2.0  \n",
       "4652    0.621286            2.0  \n",
       "4650    0.612264            3.0  \n",
       "4649    0.554155            2.0  \n",
       "4647    0.523005            2.0  \n",
       "4644    0.532497            2.0  \n",
       "4643    0.532414            1.0  \n",
       "4641    0.551859            2.0  \n",
       "4639    0.563889            2.0  \n",
       "4636    0.607655            3.0  \n",
       "4634    0.572968            2.0  \n",
       "4632    0.588815            2.0  \n",
       "4631    0.578020            4.0  \n",
       "4628    0.597628            1.0  \n",
       "4626    0.574618            2.0  \n",
       "4625    0.578149            3.0  \n",
       "4623    0.580656            2.0  \n",
       "4621    0.569151            2.0  \n",
       "\n",
       "[39 rows x 49 columns]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Example Output of Game Logs\n",
    "gameLogs[(gameLogs['TEAM_ID'] == 1610612737 ) & (gameLogs['SEASON'] == '2022-23')].sort_values('GAME_DATE')"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Feature Engineered Dataset \n",
    "This function produces the dataset with all current feature variables for modeling and additional columns to perform a training set/validation set split. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "def getGameLogFeatureSet(gameDF):\n",
    "\n",
    "    def shiftGameLogRecords(gameDF):\n",
    "        gameDF['LAST_GAME_OE'] = gameLogs.sort_values('GAME_DATE').groupby(['TEAM_ID','SEASON'])['OFFENSIVE_EFFICIENCY'].shift(1)\n",
    "        gameDF['LAST_GAME_HOME_WIN_PCTG'] = gameDF.sort_values('GAME_DATE').groupby(['TEAM_ID','SEASON'])['HOME_WIN_PCTG'].shift(1)\n",
    "        gameDF['LAST_GAME_AWAY_WIN_PCTG'] = gameDF.sort_values('GAME_DATE').groupby(['TEAM_ID','SEASON'])['AWAY_WIN_PCTG'].shift(1)\n",
    "        gameDF['LAST_GAME_TOTAL_WIN_PCTG'] = gameDF.sort_values('GAME_DATE').groupby(['TEAM_ID','SEASON'])['TOTAL_WIN_PCTG'].shift(1)\n",
    "        gameDF['LAST_GAME_ROLLING_SCORING_MARGIN'] = gameDF.sort_values('GAME_DATE').groupby(['TEAM_ID','SEASON'])['ROLLING_SCORING_MARGIN'].shift(1)\n",
    "        gameDF['LAST_GAME_ROLLING_OE'] = gameDF.sort_values('GAME_DATE').groupby(['TEAM_ID','SEASON'])['ROLLING_OE'].shift(1)\n",
    "    \n",
    "    \n",
    "    def getHomeTeamFrame(gameDF):\n",
    "        homeTeamFrame = gameDF[gameDF['CITY'] != 'OPPONENTS']\n",
    "        homeTeamFrame = homeTeamFrame[['LAST_GAME_OE','LAST_GAME_HOME_WIN_PCTG','NUM_REST_DAYS','LAST_GAME_AWAY_WIN_PCTG','LAST_GAME_TOTAL_WIN_PCTG','LAST_GAME_ROLLING_SCORING_MARGIN','LAST_GAME_ROLLING_OE','W','TEAM_ID','GAME_ID','SEASON']]\n",
    "\n",
    "        colRenameDict = {}\n",
    "        for col in homeTeamFrame.columns:\n",
    "            if (col != 'GAME_ID') & (col != 'SEASON') :\n",
    "                colRenameDict[col] = 'HOME_' + col \n",
    "\n",
    "        homeTeamFrame.rename(columns=colRenameDict,inplace=True)\n",
    "\n",
    "        return homeTeamFrame\n",
    "\n",
    "    def getAwayTeamFrame(gameDF):\n",
    "        awayTeamFrame = gameDF[gameDF['CITY'] == 'OPPONENTS']\n",
    "        awayTeamFrame = awayTeamFrame[['LAST_GAME_OE','LAST_GAME_HOME_WIN_PCTG','NUM_REST_DAYS','LAST_GAME_AWAY_WIN_PCTG','LAST_GAME_TOTAL_WIN_PCTG','LAST_GAME_ROLLING_SCORING_MARGIN','LAST_GAME_ROLLING_OE','TEAM_ID','GAME_ID','SEASON']]\n",
    "\n",
    "        colRenameDict = {}\n",
    "        for col in awayTeamFrame.columns:\n",
    "            if (col != 'GAME_ID') & (col != 'SEASON'):\n",
    "                colRenameDict[col] = 'AWAY_' + col \n",
    "\n",
    "        awayTeamFrame.rename(columns=colRenameDict,inplace=True)\n",
    "\n",
    "        return awayTeamFrame\n",
    "    \n",
    "    shiftGameLogRecords(gameLogs)\n",
    "    awayTeamFrame = getAwayTeamFrame(gameLogs)\n",
    "    homeTeamFrame = getHomeTeamFrame(gameLogs)\n",
    "    \n",
    "    return pd.merge(homeTeamFrame, awayTeamFrame, how=\"inner\", on=[ \"GAME_ID\",\"SEASON\"]).drop(['GAME_ID','AWAY_TEAM_ID','HOME_TEAM_ID'],axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "modelData = getGameLogFeatureSet(gameLogs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>HOME_LAST_GAME_OE</th>\n",
       "      <th>HOME_LAST_GAME_HOME_WIN_PCTG</th>\n",
       "      <th>HOME_NUM_REST_DAYS</th>\n",
       "      <th>HOME_LAST_GAME_AWAY_WIN_PCTG</th>\n",
       "      <th>HOME_LAST_GAME_TOTAL_WIN_PCTG</th>\n",
       "      <th>HOME_LAST_GAME_ROLLING_SCORING_MARGIN</th>\n",
       "      <th>HOME_LAST_GAME_ROLLING_OE</th>\n",
       "      <th>HOME_W</th>\n",
       "      <th>SEASON</th>\n",
       "      <th>AWAY_LAST_GAME_OE</th>\n",
       "      <th>AWAY_LAST_GAME_HOME_WIN_PCTG</th>\n",
       "      <th>AWAY_NUM_REST_DAYS</th>\n",
       "      <th>AWAY_LAST_GAME_AWAY_WIN_PCTG</th>\n",
       "      <th>AWAY_LAST_GAME_TOTAL_WIN_PCTG</th>\n",
       "      <th>AWAY_LAST_GAME_ROLLING_SCORING_MARGIN</th>\n",
       "      <th>AWAY_LAST_GAME_ROLLING_OE</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.555556</td>\n",
       "      <td>0.685714</td>\n",
       "      <td>3.0</td>\n",
       "      <td>0.444444</td>\n",
       "      <td>0.563380</td>\n",
       "      <td>9.333333</td>\n",
       "      <td>0.571405</td>\n",
       "      <td>1</td>\n",
       "      <td>2020-21</td>\n",
       "      <td>0.612903</td>\n",
       "      <td>0.250000</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.228571</td>\n",
       "      <td>0.239437</td>\n",
       "      <td>-2.000000</td>\n",
       "      <td>0.605315</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.573913</td>\n",
       "      <td>0.676471</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.444444</td>\n",
       "      <td>0.557143</td>\n",
       "      <td>-0.666667</td>\n",
       "      <td>0.589472</td>\n",
       "      <td>1</td>\n",
       "      <td>2020-21</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.305556</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.303030</td>\n",
       "      <td>0.304348</td>\n",
       "      <td>-18.000000</td>\n",
       "      <td>0.512228</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.584746</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.444444</td>\n",
       "      <td>0.550725</td>\n",
       "      <td>8.666667</td>\n",
       "      <td>0.640592</td>\n",
       "      <td>1</td>\n",
       "      <td>2020-21</td>\n",
       "      <td>0.612403</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.428571</td>\n",
       "      <td>0.463768</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.567718</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.609756</td>\n",
       "      <td>0.656250</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.444444</td>\n",
       "      <td>0.544118</td>\n",
       "      <td>11.333333</td>\n",
       "      <td>0.653327</td>\n",
       "      <td>1</td>\n",
       "      <td>2020-21</td>\n",
       "      <td>0.539568</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.441176</td>\n",
       "      <td>0.470588</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.570866</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.512397</td>\n",
       "      <td>0.354839</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.558824</td>\n",
       "      <td>0.461538</td>\n",
       "      <td>11.000000</td>\n",
       "      <td>0.596498</td>\n",
       "      <td>1</td>\n",
       "      <td>2020-21</td>\n",
       "      <td>0.727273</td>\n",
       "      <td>0.656250</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.457143</td>\n",
       "      <td>0.552239</td>\n",
       "      <td>17.333333</td>\n",
       "      <td>0.633081</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2900</th>\n",
       "      <td>0.578512</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.250000</td>\n",
       "      <td>0.285714</td>\n",
       "      <td>-9.000000</td>\n",
       "      <td>0.565270</td>\n",
       "      <td>1</td>\n",
       "      <td>2022-23</td>\n",
       "      <td>0.537037</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.300000</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.622617</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2901</th>\n",
       "      <td>0.540146</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.562500</td>\n",
       "      <td>3.333333</td>\n",
       "      <td>0.556248</td>\n",
       "      <td>1</td>\n",
       "      <td>2022-23</td>\n",
       "      <td>0.511278</td>\n",
       "      <td>0.142857</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.300000</td>\n",
       "      <td>0.235294</td>\n",
       "      <td>-5.000000</td>\n",
       "      <td>0.555121</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2902</th>\n",
       "      <td>0.490909</td>\n",
       "      <td>0.250000</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>0.300000</td>\n",
       "      <td>-17.666667</td>\n",
       "      <td>0.488297</td>\n",
       "      <td>0</td>\n",
       "      <td>2022-23</td>\n",
       "      <td>0.568966</td>\n",
       "      <td>0.400000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.400000</td>\n",
       "      <td>0.400000</td>\n",
       "      <td>-12.666667</td>\n",
       "      <td>0.565603</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2903</th>\n",
       "      <td>0.531250</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>-0.333333</td>\n",
       "      <td>0.547383</td>\n",
       "      <td>1</td>\n",
       "      <td>2022-23</td>\n",
       "      <td>0.533898</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>-9.666667</td>\n",
       "      <td>0.549413</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2904</th>\n",
       "      <td>0.513043</td>\n",
       "      <td>0.307692</td>\n",
       "      <td>3.0</td>\n",
       "      <td>0.214286</td>\n",
       "      <td>0.259259</td>\n",
       "      <td>-14.333333</td>\n",
       "      <td>0.556458</td>\n",
       "      <td>0</td>\n",
       "      <td>2022-23</td>\n",
       "      <td>0.577236</td>\n",
       "      <td>0.307692</td>\n",
       "      <td>3.0</td>\n",
       "      <td>0.187500</td>\n",
       "      <td>0.241379</td>\n",
       "      <td>-8.000000</td>\n",
       "      <td>0.512440</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2905 rows × 16 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      HOME_LAST_GAME_OE  HOME_LAST_GAME_HOME_WIN_PCTG  HOME_NUM_REST_DAYS  \\\n",
       "0              0.555556                      0.685714                 3.0   \n",
       "1              0.573913                      0.676471                 1.0   \n",
       "2              0.584746                      0.666667                 2.0   \n",
       "3              0.609756                      0.656250                 4.0   \n",
       "4              0.512397                      0.354839                 1.0   \n",
       "...                 ...                           ...                 ...   \n",
       "2900           0.578512                      0.333333                 4.0   \n",
       "2901           0.540146                      0.600000                 2.0   \n",
       "2902           0.490909                      0.250000                 2.0   \n",
       "2903           0.531250                      1.000000                 2.0   \n",
       "2904           0.513043                      0.307692                 3.0   \n",
       "\n",
       "      HOME_LAST_GAME_AWAY_WIN_PCTG  HOME_LAST_GAME_TOTAL_WIN_PCTG  \\\n",
       "0                         0.444444                       0.563380   \n",
       "1                         0.444444                       0.557143   \n",
       "2                         0.444444                       0.550725   \n",
       "3                         0.444444                       0.544118   \n",
       "4                         0.558824                       0.461538   \n",
       "...                            ...                            ...   \n",
       "2900                      0.250000                       0.285714   \n",
       "2901                      0.500000                       0.562500   \n",
       "2902                      0.333333                       0.300000   \n",
       "2903                      0.500000                       0.666667   \n",
       "2904                      0.214286                       0.259259   \n",
       "\n",
       "      HOME_LAST_GAME_ROLLING_SCORING_MARGIN  HOME_LAST_GAME_ROLLING_OE  \\\n",
       "0                                  9.333333                   0.571405   \n",
       "1                                 -0.666667                   0.589472   \n",
       "2                                  8.666667                   0.640592   \n",
       "3                                 11.333333                   0.653327   \n",
       "4                                 11.000000                   0.596498   \n",
       "...                                     ...                        ...   \n",
       "2900                              -9.000000                   0.565270   \n",
       "2901                               3.333333                   0.556248   \n",
       "2902                             -17.666667                   0.488297   \n",
       "2903                              -0.333333                   0.547383   \n",
       "2904                             -14.333333                   0.556458   \n",
       "\n",
       "      HOME_W   SEASON  AWAY_LAST_GAME_OE  AWAY_LAST_GAME_HOME_WIN_PCTG  \\\n",
       "0          1  2020-21           0.612903                      0.250000   \n",
       "1          1  2020-21           0.500000                      0.305556   \n",
       "2          1  2020-21           0.612403                      0.500000   \n",
       "3          1  2020-21           0.539568                      0.500000   \n",
       "4          1  2020-21           0.727273                      0.656250   \n",
       "...      ...      ...                ...                           ...   \n",
       "2900       1  2022-23           0.537037                      0.666667   \n",
       "2901       1  2022-23           0.511278                      0.142857   \n",
       "2902       0  2022-23           0.568966                      0.400000   \n",
       "2903       1  2022-23           0.533898                      1.000000   \n",
       "2904       0  2022-23           0.577236                      0.307692   \n",
       "\n",
       "      AWAY_NUM_REST_DAYS  AWAY_LAST_GAME_AWAY_WIN_PCTG  \\\n",
       "0                    2.0                      0.228571   \n",
       "1                    2.0                      0.303030   \n",
       "2                    2.0                      0.428571   \n",
       "3                    2.0                      0.441176   \n",
       "4                    1.0                      0.457143   \n",
       "...                  ...                           ...   \n",
       "2900                 2.0                      0.300000   \n",
       "2901                 2.0                      0.300000   \n",
       "2902                 1.0                      0.400000   \n",
       "2903                 3.0                      0.000000   \n",
       "2904                 3.0                      0.187500   \n",
       "\n",
       "      AWAY_LAST_GAME_TOTAL_WIN_PCTG  AWAY_LAST_GAME_ROLLING_SCORING_MARGIN  \\\n",
       "0                          0.239437                              -2.000000   \n",
       "1                          0.304348                             -18.000000   \n",
       "2                          0.463768                               0.666667   \n",
       "3                          0.470588                               0.666667   \n",
       "4                          0.552239                              17.333333   \n",
       "...                             ...                                    ...   \n",
       "2900                       0.500000                               0.000000   \n",
       "2901                       0.235294                              -5.000000   \n",
       "2902                       0.400000                             -12.666667   \n",
       "2903                       0.333333                              -9.666667   \n",
       "2904                       0.241379                              -8.000000   \n",
       "\n",
       "      AWAY_LAST_GAME_ROLLING_OE  \n",
       "0                      0.605315  \n",
       "1                      0.512228  \n",
       "2                      0.567718  \n",
       "3                      0.570866  \n",
       "4                      0.633081  \n",
       "...                         ...  \n",
       "2900                   0.622617  \n",
       "2901                   0.555121  \n",
       "2902                   0.565603  \n",
       "2903                   0.549413  \n",
       "2904                   0.512440  \n",
       "\n",
       "[2905 rows x 16 columns]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Final Data Set before Train,Test, Validation Split\n",
    "modelData"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "modelData.to_csv('nbaHomeWinLossModelDataset.csv')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
